package com.yingpai.fitness.dvp_2_0.main.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yingpai.fitness.R;
import com.yingpai.fitness.dvp_2_0.main.activity.fitness.RunStrategyActivity;
import com.yingpai.fitness.dvp_2_0.common.adapter.BaseSimplePagerAdapter;
import com.yingpai.fitness.entity.RunBean;

import java.util.List;

public class BikeTopPagerAdapter extends BaseSimplePagerAdapter<RunBean.MapBean.UpBannersBean> {

    private Context context;

    public BikeTopPagerAdapter(Context context, List<RunBean.MapBean.UpBannersBean> views) {
        super(context, views);
        this.context = context;
    }

    @Override
    protected void setViewData(View view, final RunBean.MapBean.UpBannersBean bean) {
        ImageView imag = (ImageView) view.findViewById(R.id.intro_img);
        Glide.with(context)
                .load(bean.getPhotoUrl())
                .error(R.mipmap.default_big_bg)
                .into(imag);
        imag.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("linkurl", bean.getLinkUrl());
                Intent intent = new Intent(context, RunStrategyActivity.class);
                intent.putExtras(bundle);
                ActivityCompat.startActivity(context, intent, ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context).toBundle());
            }
        });
    }

    @Override
    public View CreateItemView(Context context) {
        return LayoutInflater.from(context).inflate(R.layout.dvp_2_0_vpitem, null);
    }
}
